package com.example.demo.config;

import com.example.demo.pojo.PlannerResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandle {
    @ExceptionHandler(Exception.class)
    public PlannerResult<String> exception(Exception e) {
        log.error(e.getMessage());
        return PlannerResult.error(StringUtils.hasLength(e.getMessage())?e.getMessage():"操作失败");
    }
}
